package com.tanlu.hbase.admin.api;

import com.gitee.easyopen.annotation.Api;
import com.gitee.easyopen.annotation.ApiService;
import com.spring4all.spring.boot.starter.hbase.api.HbaseTemplate;
import com.tanlu.hbase.admin.dto.HbaseReqDto;
import com.tanlu.hbase.admin.dto.ResultDto;
import com.tanlu.hbase.admin.mapper.FirstPushHbaseMapper;
import com.tanlu.hbase.admin.mapper.SecondPushHbaseMapper;
import com.tanlu.hbase.admin.service.HbaseService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;

@ApiService
public class ForeignApi {

    private static Logger logger = LoggerFactory.getLogger(ForeignApi.class);


    @Autowired
    private HbaseTemplate hbaseTemplate;
    @Autowired
    HbaseService hbaseService;

    @Api(name = "getByOrderNo")
    public ResultDto getByOrderNo(@RequestBody HbaseReqDto o) {
        ResultDto resultDto = new ResultDto();
        resultDto.setCode("200");
        logger.info("一推查询Hbase："+ o.getTableName()+","+ o.getKey());
         resultDto.setData(hbaseTemplate.get(o.getTableName(), o.getKey(), new FirstPushHbaseMapper()).getBaseInfo().getKfkPush());
        return resultDto;
    }

    @Api(name = "getSecondByOrderNo")
    public ResultDto getSecondByOrderNo(@RequestBody HbaseReqDto o) {
        ResultDto resultDto = new ResultDto();
        resultDto.setCode("200");
        logger.info("二推查询Hbase: " + o.getTableName()+","+ o.getKey());
        resultDto.setData(hbaseTemplate.get(o.getTableName(), o.getKey(), new SecondPushHbaseMapper()).getBaseInfo().getKfkPush());
        return resultDto;
    }
}
